import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { h } from 'vue';
import { TriangleDownFilled } from 'ant-design-vue/icons'; // 正确路径：ant-design-vue/icons
import { WarningOutlined } from '@ant-design/icons-vue';

export const columns: BasicColumn[] = [
    {
        title: 'licenseName',
        dataIndex: 'licenseName'
    },
    {
        title: 'issuedTime',
        dataIndex: 'issuedTime'
    },
    {
        title: 'expiryTime',
        dataIndex: 'expiryTime',
        sorter: true,
        customRender: ({ text }) => {
            const expiryDate = new Date(text);
            const now = new Date();
            if (expiryDate < now) {
                return h('span', { style: { color: 'red' } }, text);
            }
            return text;
        }
    },
    {
        title: '描述',
        dataIndex: 'description',
        ifShow: false
    },
    {
        title: 'mssp',
        dataIndex: 'mssp'
    },
    {
        title: '证书生成状态',
        dataIndex: 'licenseFileGenerated',
        ifShow: false
    },
];

export const searchFormSchema: FormSchema[] = [
 {
    label: 'licenseName',
    field: 'licenseName',
    component: 'Input'
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  {label: '', field: 'id', component: 'Input', show: false},
  {
    label: 'licenseName',
    field: 'licenseName',
    component: 'Input',
    componentProps:{
      style: 'height:40px;',
    }
  },
  // {
  //   label: 'machineCode',
  //   field: 'machineCode',
  //   component: 'Input',
  // },
  {
    label: 'issuedTime',
    field: 'issuedTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      style: 'height:40px;',
    },
    rules: [
      {
        required: true,
        message: '请选择签发时间',
      }
    ]
  },
  {
    label: 'expiryTime',
    field: 'expiryTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      style: 'height:40px;',
    },
    rules: [
      {
        required: true,
        message: '请选择过期时间',
      },
    ]
  },
  {
    label: '描述',
    field: 'description',
    component: 'Input',
    componentProps:{
      style: 'height:40px;',
    }
  },
  {
    label: 'mssp',
    field: 'jsonStr',
    component: 'JCheckbox',
    slot: 'mssp',
  },

];
